package cn.com.chengmandian.bike.service.impl;

import cn.com.chengmandian.bike.dto.FaultSoftwareAddForm;
import cn.com.chengmandian.bike.dto.FaultSoftwareDto;
import cn.com.chengmandian.bike.mapper.EbFaultSoftwareMapper;
import cn.com.chengmandian.bike.model.EbFaultSoftware;
import cn.com.chengmandian.bike.model.vo.FaultSoftwareVo;
import cn.com.chengmandian.bike.service.IEbFaultSoftwareService;
import cn.com.chengmandian.core.common.constants.CommonConstant;
import cn.com.chengmandian.core.common.utils.BillNoUtil;
import cn.com.chengmandian.core.web.pojo.AgentUser;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 电单车运营-软件问题反馈 服务实现类
 * </p>
 *
 * @author AutoGenerator
 * @since 2021-12-23
 */
@Service
public class EbFaultSoftwareServiceImpl extends ServiceImpl<EbFaultSoftwareMapper, EbFaultSoftware> implements IEbFaultSoftwareService {

    @Override
    public void addSoftware(FaultSoftwareAddForm faultSoftwareAddForm, AgentUser agentUser) {
        EbFaultSoftware faultSoftware = new EbFaultSoftware();
        faultSoftware.setAreaId(faultSoftwareAddForm.getAreaId());
        faultSoftware.setNo(BillNoUtil.getSimpleNo("FS-"));
        faultSoftware.setMemberId(agentUser.getId());
        faultSoftware.setTypes(faultSoftwareAddForm.getTypes());
        faultSoftware.setContent(faultSoftwareAddForm.getContent());
        faultSoftware.setImgUrl(faultSoftware.getImgUrl());
        faultSoftware.setStatus(CommonConstant.ZERO);
        this.save(faultSoftware);
    }

    @Override
    public IPage<FaultSoftwareVo> getPage(FaultSoftwareDto dto, Integer memberId) {
        Page page = Page.of(dto.getPageNumber(), dto.getPageSize());
        return baseMapper.getPage(page, dto,memberId);
    }
}
